<?php 
require_once (dirname(__FILE__)."/services.php");
class demo_RouterExtension extends Extension {
    public function apply(&$context, Chain $chain) {
        $context['rule']['{^/demo/*$}'] = dirname(__FILE__)."/actions.php";
        $context['rule']['{^/admin/demo/*$}'] = dirname(__FILE__)."/actions.php";
        $chain->next($context);
    }
}

class demoFeature extends Feature {
    public function registerExtension() {
        $this->extensions = Array( 
              	 new demo_RouterExtension("com.yizin.platform.router")
		);
    }
    
    public function registerExtendable() {
    }
    
    public function init() {
    	$conn = getDBConnection();
		$conn->query('drop table if exists demo;');
		
    	$conn->query('
		create table demo (
	id bigint primary key auto_increment,
	content text not null
) CHARSET=utf8;
		');
		$conn->query('insert into demo(content) values("");');
		
		$conn->disconnect();
	}
    
    public function destroy() {
    	$conn=getDBConnection();
		$conn->query('drop table if exists demo;');
		$conn->disconnect();
    }
}

$featureClass = "demoFeature";
$featureName = "Demo";
$featureIntroduction = "demo feature";
?>
